﻿import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt.labs.platform
import FilUI

import "../controls"

FilWindow {
    id: window

    title: qsTr("Friendly Reminder")
    width: 600
    height: 250
    fixSize: true
    showMaximize: false

    property string crashFilePath

    Component.onCompleted: {
        var args = Qt.application.arguments
        if (args.length>=2 && args[1].startsWith("-crashed=")) {
            crashFilePath = args[1].replace("-crashed=","")
            console.log("crashFilePath=", crashFilePath)
        }
        window.stayTop = true
    }

    FilText {
        id: text_info
        anchors {
            centerIn: parent
        }
        wrapMode: Text.WrapAnywhere
        text: qsTr("We apologize for the inconvenience caused by an unexpected error")
        horizontalAlignment: Text.AlignHCenter
        verticalAlignment: Text.AlignVCenter
    }

    RowLayout{
        anchors {
            horizontalCenter: parent.horizontalCenter
            bottom: parent.bottom
            bottomMargin: 20
        }
        FilButton {
            text: qsTr("Report Logs")
            onClicked: {
                window.stayTop = false
                FilTools.showFileInFolder(crashFilePath)
            }
        }
        Item{
            width: 30
            height: 1
        }
        FilFilledButton {
            text: qsTr("Restart Program")
            onClicked: {
                Qt.exit(931)
            }
        }
    }
}
